package com.bw.ppjokeplay.mvvm.viewmodel.sofa

import com.bw.ppjokeplay.adapter.SofaImgListAdapter
import com.bw.ppjokeplay.adapter.SofatextListAdapter
import com.bw.ppjokeplay.commen.entity.BaseEntity
import com.bw.ppjokeplay.commen.mvvm.viewmodel.BaseViewModel
import com.bw.ppjokeplay.mvvm.model.entity.HomeFeedEntity
import com.bw.ppjokeplay.mvvm.model.sofa.SofaTxtModel
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * @author Lishaohe
 * @description:
 * @date :2021/11/12 0012 上午 11:23
 *
 */
class SofaTxtViewModel : BaseViewModel<SofaTxtModel>() {
    private var pageCount : Int = 12
    private val feedId = 0;
    private val feedType = "text"
    private var userId = 0
    val adapter : SofatextListAdapter = SofatextListAdapter()
    var homeFeedEntity : HomeFeedEntity?=null
    override fun initdata() {
        m.requestsofaList(feedId, feedType, pageCount, userId)!!
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(this)
    }

    override fun result(t: BaseEntity) {
        if(t is HomeFeedEntity){
            homeFeedEntity = t as HomeFeedEntity
            adapter.setNewInstance(homeFeedEntity!!.data!!.data)
        }
    }
}